/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 17655
 * Date: 2025-03-02
 * Time: 12:51
 */
public class test1 {
    /**
     * LeetCode  1137  第N个泰波那契数
     */

    public int tribonacci(int n) {
        if(n==0 || n==1){
            return n;
        }
        if(n==2){
            return 1;
        }
        int[] dp = new int[n+1];
        dp[0] = 0;
        dp[1] = dp[2] = 1;
        for(int i=3;i<=n;i++){
            dp[i] = dp[i-3]+dp[i-2]+dp[i-1];
        }
        return dp[n];
    }
}
